package com.suneee.trades.service;

import java.util.List;
import java.util.Map;

import com.suneee.context.page.Page;
import com.suneee.quartz.dao.ScheduleTimeDao;
import com.suneee.quartz.entity.TmallOrderEn;
import com.suneee.store.dao.ShopStockDao;
import com.suneee.store.service.ProductService;
import com.suneee.trades.bean.OrderInfoDTO;
import com.suneee.trades.bean.SendGoodsResult;
import com.suneee.trades.bean.SynLogDTO;
import com.suneee.trades.bean.TradesInfoDTO;
import com.suneee.trades.dao.PromotionDetailsDao;
import com.suneee.trades.dao.SynLogDao;
import com.suneee.trades.dao.TradesInfoDao;
import com.suneee.trades.dao.TradesOrderDao;
import com.suneee.trades.entity.OrderLog;
import com.suneee.trades.entity.Shopp;
import com.suneee.trades.entity.SynLog;
import com.suneee.trades.entity.TradesInfo;
import com.suneee.trades.entity.TradesOrder;
import com.suneee.trades.entity.ViewShopp;
import com.suneee.web.bean.DownloadInfo;
import com.suneee.web.bean.UploadInfo;

public interface TradesInfoService {

	/**
	 * 获取订单信息及可合并订单下的商品列表
	 * 
	 * @return
	 */
	public TradesInfo getCanCombinedOrder(TradesInfoDTO dto);

	/**
	 * 合并订单
	 * 
	 * @param dto
	 */
	public void combinedOrders(TradesInfoDTO dto);

	/**
	 * 解锁订单
	 * 
	 * @param tids
	 */
	public void unlockTrades(TradesInfoDTO dto);

	/**
	 * 拆单
	 * 
	 * @param dto
	 */
	public void splitOrders(TradesInfoDTO dto);
	
	
	/**
	 * 新建订单
	 * @param dto
	 */
	public void createOrder(OrderInfoDTO dto);
	

	/**
	 * 查询历史订单
	 * 
	 * @param dto
	 * @return
	 */
//	public Page<TradesInfo> historyOrders(TradesInfoDTO dto);
	
	public Page<Map<String, Object>> historyOrders(TradesInfoDTO dto);

	/**
	 * 导出历史订单
	 * 
	 * @param dto
	 * @return
	 */
	public DownloadInfo exportOrders(Integer payTimeSort, String tid, Integer shopId, String buyerNick,
			String tradeType, String payStartTime, String payEndTime, String shoppStartTime, String shoppEndTime);

	/**
	 * 发货单查询
	 * (包含未发货和发货失败的记录)
	 * @param dto
	 * @return
	 */
	public Page<ViewShopp> selectWaitSendGoods(TradesInfoDTO dto);
	
	/**
	 * 发货单查询
	 * (包含已发货成功的记录)
	 * @param dto
	 * @return
	 */
	public Page<ViewShopp> selectSendGoods(TradesInfoDTO dto);

	/**
	 * 发货
	 * 
	 * @param dto
	 */
	public SendGoodsResult sendGoods(TradesInfoDTO dto);

	/**
	 * 导出待发货订单
	 * 
	 * @param dto
	 * @return
	 */
	public DownloadInfo exportWaitSendGoods(String title,Integer shopId,String companyName,String buyerNick,String tid,String createStartTime,String createEndTime,String reviewStartTime,String reviewEndTime,Integer[] shoppId);

	/**
	 * 导入发货单
	 */
	public SendGoodsResult importWaitSendGoods(UploadInfo info);
	

	/**
	 * 手工同步订单
	 * 
	 * @param entity
	 * @return
	 */
	public SynLog manualSyncOrder(TmallOrderEn entity) throws Exception;

	/**
	 * 获取订单详细信息
	 * 
	 * @param tId
	 * @return
	 */
	public TradesInfo orderDetial(String tId);

	/**
	 * 提交发货
	 * 
	 * @param tid
	 */
	public void submitOrder(TradesInfo info);

	/**
	 * 订单状态修改（延迟发货、重新理单、解锁场景下使用
	 * 
	 * @param dto
	 */
	public void modifyOrder(TradesInfoDTO dto);

	/**
	 * 修改物流
	 * 
	 * @param dto
	 */
	public TradesInfo modifyLogistics(TradesInfoDTO dto);

	/**
	 * 待审单列表
	 * 
	 * @param dto
	 * @return
	 */
 	public Page<Map<String, Object>> examinList(TradesInfoDTO dto);
	

	/**
	 * 同步记录查询
	 * @return
	 */
	public Page<Map<String, Object>> synchronizeOrderInfo(SynLogDTO dto);
	
	/**
	 * 更新交易信息相关表
	 * @param entity  数据封装类
	 * @param shopId  店铺ID
	 * @param enterpriseCode 企业编码
	 * @param totalResults 总行数
	 * @param opType 同步方式
	 * @param createUser 同步操作人
	 */
	public void updateSynLogTable(TmallOrderEn entity,Integer shopId,String enterpriseCode, Long totalResults, String opType, String createUser,
			String interva,TradesOrderDao tradesOrderDao,TradesInfoDao tradesInfoDao,ShopStockDao shopStockDao,ProductService productService,PromotionDetailsDao promotionDetailsDao,
			SynLogDao synLogDao,ScheduleTimeDao scheduleTimeDao);
	
	public Shopp createShopp(Integer createUserId, String companyCode);

	public void createShoppDetail(List<TradesOrder> achieveOrders, Integer shoppId);
	
	/**
	 * 生成订单处理日志
	 * @param tid
	 * @param isSuccess
	 * @param adminId
	 * @param opContent
	 * @param busiType
	 * @param result
	 * @param remark
	 * @return
	 */
	public OrderLog createOrderLog(String tid, String isSuccess, Integer adminId, String opContent, String busiType,String result,String remark);
}
